<template>
  <div>
    <div ref="box" style="width: 100%;height: 400px"></div>
  </div>
</template>

<script>
const echarts = require('echarts')
export default {
  name: "home",
  mounted() {
    this.init()
  },
  destroyed() {
    window.removeEventListener('resize',this.myechart.resize)
  },
  methods: {
    init(){
      console.log('图表初始化')
      this.myechart = echarts.init(this.$refs.box)
      window.addEventListener('resize',this.myechart.resize)
    },
    setOption(options){
      this.myechart.setOption(options)
    }
  }
}
</script>

<style scoped>

</style>
